package cn.ingrun.utils.responseUtil;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;

public class ResponseUtils extends ResponseEntity<ResponseModel> {

    public ResponseUtils(HttpStatus status) {
        super(status);
    }

    public ResponseUtils(ResponseModel body, HttpStatus status) {
        super(body, status);
    }

    public ResponseUtils(MultiValueMap<String, String> headers, HttpStatus status) {
        super(headers, status);
    }

    public ResponseUtils(ResponseModel body, MultiValueMap<String, String> headers, HttpStatus status) {
        super(body, headers, status);
    }

    public static ResponseUtils auto(boolean bool){
        if (bool){
            return ResponseUtils.success( "true", HttpStatus.OK);
        }
        return ResponseUtils.error("false", HttpStatus.OK);
    }

    public static ResponseUtils success(){
        return new ResponseUtils(HttpStatus.OK);
    }

    public static ResponseUtils success(HttpStatus httpStatus){
        return new ResponseUtils(httpStatus);
    }

    public static ResponseUtils success(int code, String message, Object data){
        return new ResponseUtils(new ResponseModel(code, message, data), HttpStatus.OK);
    }

    public static ResponseUtils success(ResponseModel responseJson){
        return new ResponseUtils(responseJson, HttpStatus.OK);
    }

    public static ResponseUtils success(int code, String message, Object data, HttpStatus httpStatus){
        return new ResponseUtils(new ResponseModel(code, message, data), httpStatus);
    }

    public static ResponseUtils success(String message){
        return new ResponseUtils(new ResponseModel(1, message, ""), HttpStatus.OK);
    }

    public static ResponseUtils success(Object date){
        return new ResponseUtils(new ResponseModel(1, "success", date), HttpStatus.OK);
    }

    public static ResponseUtils success(String message, Object date){
        return new ResponseUtils(new ResponseModel(1, message, date), HttpStatus.OK);
    }

    public static ResponseUtils error(int code, String message, Object data, HttpStatus httpStatus){
        return new ResponseUtils(new ResponseModel(code, message, data), httpStatus);
    }

    public static ResponseUtils error_404(){
        return new ResponseUtils(new ResponseModel(0, "未找到相关信息", ""), HttpStatus.NOT_FOUND);
    }

    public static ResponseUtils error(String message){
        return new ResponseUtils(new ResponseModel(0, message, ""), HttpStatus.BAD_REQUEST);
    }

    public static ResponseUtils error(String message,HttpStatus httpStatus){
        return new ResponseUtils(new ResponseModel(0, message, ""), httpStatus);
    }

    public static ResponseUtils error(ResponseModel responseJson,HttpStatus httpStatus){
        return new ResponseUtils(responseJson, httpStatus);
    }
    public static ResponseUtils error(ResponseModel responseJson){
        return new ResponseUtils(responseJson, HttpStatus.BAD_REQUEST);
    }


}
